package com.diandian.backend.log.constants;

public enum TaskStatusEnum {

    UNKNOWN("", "未知"),
    READY("1", "待执行"),
    RUNNING("2", "进行中"),
    PAUSE("3", "暂停"),
    CANCEL("4", "取消"),
    OUTTIME("6", "超时"),
    FINISH("5", "完成");

    public static String getNameByType(String type){
        for (TaskStatusEnum typeEnum: TaskStatusEnum.values()) {
            String item = typeEnum.getType();
            if(type.equals(item)){
                return typeEnum.getName();
            }
        }
        return null;
    }

    public boolean contains(String type){
        for (TaskStatusEnum typeEnum: TaskStatusEnum.values()) {
            String item = typeEnum.getType();
            if(type.equals(item)){
                return true;
            }
        }
        return false;
    }

    private String type;
    private String name;

    TaskStatusEnum(String type, String name) {
        this.type = type;
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
